package xkp.lesson2;

import java.util.ArrayList;
import java.util.Collection;

public class TestCollection {
	public static void main(String[] args) {
		//使用接口的引用指向子类对象
		Collection<String> collection = new ArrayList<String>();
		collection.add("123");
		collection.add("234");
		collection.add("345");
		System.out.println(collection.size());//3
		System.out.println(collection.isEmpty());//false
		//contains通过调用类型的equals方法判断是否包含
		System.out.println(collection.contains("123"));//true
		System.out.println(collection.contains(new String("123")));//true
		Object[] objects = collection.toArray();
		//collection.toArray(a)
		System.out.println(collection.remove("345"));
		Collection<String> collection2 = new ArrayList<String>();
		collection2.add("123");
		collection2.add("234");
		System.out.println(collection.containsAll(collection2));
		collection.addAll(collection2);
		System.out.println(collection.size());
		System.out.println(collection.removeAll(collection2));
		
		collection.clear();
		System.out.println(collection.size());
		
		
	}

}
